home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Filing / c / Filenames next >
Text File  |  1995-07-08  |  2KB  |  61 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Filing.Filenames.c
  12.     Author:  Copyright © 1994, 1995 Sergio Monesi
  13.     Version: 1.01 (6 Jun 1995)
  14.     Purpose: Finds pathnames and leafnames
  15.     Mods:    6 June 1995 - changed procedure names to a more
  16.                            DeskLib-compliant style
  17. */
  18.  
  19. #include <string.h>
  20.  
  21. #include "DeskLib:Core.h"
  22. #include "DeskLib:Filing.h"
  23.  
  24. char *Filing_GetPathname(char *filename, char *pathname)
  25. {
  26.  if (pathname==NULL || filename==NULL)
  27.    return NULL;
  28.  else {
  29.    char *p;
  30.    strcpy(pathname,filename);
  31.    p=strrchr(pathname,'.');
  32.    if (p)
  33.      *p=0;
  34.    else
  35.      *pathname=0;
  36.    return pathname;
  37.  }
  38. }
  39.  
  40. char *Filing_GetLeafname(char *filename, char *leafname)
  41. {
  42.  if (leafname==NULL || filename==NULL)
  43.    return NULL;
  44.  else {
  45.    char *p=strrchr(filename,'.');
  46.    strcpy(leafname,p?p+1:filename);
  47.    return leafname;
  48.  }
  49. }
  50.  
  51. char *Filing_FindLeafname(char *filename)
  52. {
  53.  if (filename==NULL)
  54.    return NULL;
  55.  else {
  56.    char *p=strrchr(filename,'.');
  57.    return (p?p+1:filename);
  58.  }
  59. }
  60.  
  61.